# -*- coding:utf-8 -*-
import urllib
import urllib2

url = 'http://image.baidu.com/search//acjson?tn=resultjson_com&ipn=rj&ct=201326592&is=&fp=result&queryWord=%E9%9D%92%E6%98%A5%E5%A6%B9%E5%AD%90%E5%9B%BE&cl=2&lm=-1&ie=utf-8&oe=utf-8&adpicid=&st=&z=&ic=&word=%E9%9D%92%E6%98%A5%E5%A6%B9%E5%AD%90%E5%9B%BE&s=&se=&tab=&width=&height=&face=&istype=&qc=&nc=&fr=&pn=30&rn=30&gsm=1e&1502192101260='
#url = 'https://image.baidu.com/search/index?tn=baiduimage&ipn=r&ct=201326592&cl=2&lm=-1&st=-1&fm=index&fr=&hs=0&xthttps=111111&sf=1&fmq=&pv=&ic=0&nc=1&z=&se=1&showtab=0&fb=0&width=&height=&face=0&istype=2&ie=utf-8&word=%E6%B5%B7%E8%B4%BC%E7%8E%8B&oq=haiz&rsp=0'

#请求头描述信息
header = {
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.104 Safari/537.36',
}

#包装请求对象
request = urllib2.Request(url,headers=header)

#根据请求对象发送数据请求，获取服务器返回的响应对象
response = urllib2.urlopen(request)

#获取响应对象中的数据
content = response.read()

#将获取的数据保存在文件中
with open('qing.json','w') as f:
    f.write(content)